//controlls
define(function (require, exports, module) {
    const Vue=require("vue");
    var template=require('text!./index.html');
    const utils=require('utils');
    const weui=require('weui');
    module.exports=Vue.extend({
        template:template,
        data:function () {
            return {

            }
        },
        computed:{
            isBack:function () {
                return this.$store.getters.getIsBack;
            },
            oauth:function () {
                return this.$store.getters.getOAuth;
            },
            user_info:function () {
                return this.$store.getters.getUserInfo;
            },
            user_photo:function () {
                var photo=this.user_info.user_photos;
                if(!photo){
                    if(this.oauth.open_id){
                        return this.oauth.wei_xin_user.headimgurl;
                    }
                    return 'images/person.png';
                }else{
                    return "http://app.us-ebike.com:8080/"+photo;
                }
            }
        },
        beforeRouteEnter:function (to,from,next) {
            next(function (vm) {
                if(!vm.isBack){

                }
            })
        },
        methods:{
            //清除缓存
            logOut:function () {
                var v=this;
                weui.confirm('清除缓存会退出当前账号，确定清除？', {
                    title: '',
                    buttons: [{
                        label: '取消',
                        type: 'default',
                        onClick: function(){  }
                    }, {
                        label: '确定',
                        type: 'primary',
                        onClick: function() {
                            v.$store.commit("logOut");
                            v.$router.push({path:'/phone'});
                        }
                    }]
                });
            }
        }
    });
});
